<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>添加考勤</title>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
    <style>
        /* 页面整体布局 */
        body {
            font-family: 'Arial', sans-serif;
            background-color: #f0f4f8; /* 浅蓝色背景 */
            margin: 0;
            padding: 0;
        }

        .container {
            max-width: 800px;
            margin: 50px auto;
            padding: 20px;
            background-color: #ffffff; /* 白色容器背景 */
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            border-radius: 8px;
        }

        /* 标题样式 */
        h1 {
            text-align: center;
            color: #003366; /* 深蓝色标题 */
            font-size: 28px;
            margin-bottom: 20px;
        }

        /* 表单元素样式 */
        form {
            display: flex;
            flex-direction: column;
            gap: 15px;
        }

        label {
            font-size: 16px;
            color: #333;
        }

        input[type="text"],
        input[type="date"],
        input[type="time"] {
            padding: 10px;
            border-radius: 5px;
            border: 1px solid #ccc;
            font-size: 16px;
        }

        input[type="text"]:focus,
        input[type="date"]:focus,
        input[type="time"]:focus {
            border-color: #0077cc; /* 蓝色聚焦边框 */
        }

        /* 单选框样式 */
        input[type="radio"] {
            margin-right: 5px;
        }

        /* 按钮样式 */
        button {
            padding: 10px 20px;
            background-color: #0077cc; /* 蓝色按钮 */
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 16px;
            transition: background-color 0.3s ease;
        }

        button:hover {
            background-color: #005599; /* 深蓝色按钮悬停 */
        }

        button[type="button"] {
            background-color: #f1c40f; /* 黄色按钮 */
        }

        button[type="button"]:hover {
            background-color: #e6b300; /* 深黄色按钮悬停 */
        }
    </style>
</head>

<body>
<div class="container">
    <h1>添加考勤</h1>

    <form>
        <label for="teacherid">教师编号：</label>
        <input type="text" id="teacherid" required>

        <label for="attendanceDate">日期：</label>
        <input type="date" id="attendanceDate" required>

        <label for="clockInTime">上班时间：</label>
        <input type="time" id="clockInTime" required>

        <label for="clockOutTime">下班时间：</label>
        <input type="time" id="clockOutTime" required>

        <label for="attendanceStatus">考勤状态：</label>
        <div>
            <input type="radio" id="normal" name="attendanceStatus" value="正常" checked>
            <label for="normal">正常</label>
            <input type="radio" id="late" name="attendanceStatus" value="迟到">
            <label for="late">迟到</label>
            <input type="radio" id="absent" name="attendanceStatus" value="缺勤">
            <label for="absent">早退</label>
        </div>

        <label for="remarks">备注：</label>
        <input type="text" id="remarks">

        <button type="submit" onclick="addAttendance()">添加</button>
    </form>

    <script>
        function addAttendance() {
            const attendance = getFormData();
            $.post('/attendance/add', JSON.stringify(attendance), function () {
                alert('考勤添加成功！');
                window.location.href = 'attendance.html';
            });
        }

        function getFormData() {
            return {
                teacherid: $('#teacherid').val(),
                attendanceDate: $('#attendanceDate').val(),
                clockInTime: $('#clockInTime').val(),
                clockOutTime: $('#clockOutTime').val(),
                attendanceStatus: $("input[name='attendanceStatus']:checked").val(),
                remarks: $('#remarks').val()
            };
        }
    </script>
</div>
</body>

</html>